Conditions | 3 |
Total Lines | 25 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 3 |
Changes | 0 |
1 | 1 | const db = require("../db/database.js"); |
|
25 | function addDelivery(res, body) { |
||
26 | 6 | const sql = "INSERT INTO deliveries (deliveryId, productId, amount, deliveryDate," + |
|
27 | " comment, apiKey) VALUES (?, ?, ?, ?, ?, ?)"; |
||
28 | |||
29 | 6 | db.run(sql, |
|
30 | body.id, |
||
31 | body.product_id, |
||
32 | body.amount, |
||
33 | body.delivery_date, |
||
34 | body.comment, |
||
35 | body.api_key, (err) => { |
||
36 | 6 | if (err) { |
|
37 | 5 | return res.status(500).json({ |
|
38 | errors: { |
||
39 | status: 500, |
||
40 | source: "/delivery", |
||
41 | title: "Database error", |
||
42 | detail: err.message |
||
43 | } |
||
44 | }); |
||
45 | } else { |
||
46 | 1 | res.status(201).json({ data: body }); |
|
47 | } |
||
48 | }); |
||
49 | } |
||
50 | |||
56 |